import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.ConnectionEvent;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2024-07-08
 * Time: 21:28
 */
public class Test {
    public static void main(String[] args) throws SQLException {
        DataSource dataSource = new MysqlDataSource();
        ((MysqlDataSource)dataSource).setUrl("jdbc:mysql://127.0.0.1:3306/java112?characterEncoding=utf8&useSSL=false");
        ((MysqlDataSource)dataSource).setUser("root");
        ((MysqlDataSource)dataSource).setPassword("071711");

        Connection connection = dataSource.getConnection();

        String sql = "create table student2(id int,name varchar(40))";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);

        int n = preparedStatement.executeUpdate();
        System.out.println(n);

        preparedStatement.close();
        connection.close();




    }
}

